/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('quickbi-public', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CancelCollectionRequest {
  userId?: string(name='UserId', example='121344444790****'),
  worksId?: string(name='WorksId', example='d23e84a1-82a0-4292-bfdb-521306c3****'),
}

model CancelCollectionResponseBody = {
  requestId?: string(name='RequestId', example='68383D95-D623-4059-AF1B-2310957FA332'),
  result?: boolean(name='Result', example='true'),
  success?: boolean(name='Success', example='true'),
}

model CancelCollectionResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CancelCollectionResponseBody(name='body'),
}

/**
  * **true******
  *
  * @param request CancelCollectionRequest
  * @param runtime runtime options for this request RuntimeOptions
  * @return CancelCollectionResponse
 */
async function cancelCollectionWithOptions(request: CancelCollectionRequest, runtime: Util.RuntimeOptions): CancelCollectionResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  if (!Util.isUnset(request.worksId)) {
    query['WorksId'] = request.worksId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CancelCollection',
    version = '2020-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
  * **true******
  *
  * @param request CancelCollectionRequest
  * @return CancelCollectionResponse
 */
async function cancelCollection(request: CancelCollectionRequest): CancelCollectionResponse {
  var runtime = new Util.RuntimeOptions{};
  return cancelCollectionWithOptions(request, runtime);
}

model ListCollectionsRequest {
  userId?: string(name='UserId', example='fe67f61a35a94b7da1a34ba174a7****'),
}

model ListCollectionsResponseBody = {
  requestId?: string(name='RequestId', example='C67ABB01-F057-48A5-899E-D72682B0B214'),
  result?: [ 
    {
      favoriteId?: int32(name='FavoriteId', example='12373'),
      ownerId?: string(name='OwnerId', example='fe67f61a35a94b7da1a34ba174a7****'),
      worksId?: string(name='WorksId', example='355dd2c5-ffe2-4692-bd12-a2696b43****'),
      worksName?: string(name='WorksName'),
      worksType?: string(name='WorksType', example='dashboardOfflineQuery'),
      workspaceId?: string(name='WorkspaceId', example='9337d121-a78f-4c1b-a8bc-f81de117****'),
      workspaceName?: string(name='WorkspaceName'),
    }
  ](name='Result'),
  success?: boolean(name='Success', example='true'),
}

model ListCollectionsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListCollectionsResponseBody(name='body'),
}

async function listCollectionsWithOptions(request: ListCollectionsRequest, runtime: Util.RuntimeOptions): ListCollectionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListCollections',
    version = '2020-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listCollections(request: ListCollectionsRequest): ListCollectionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listCollectionsWithOptions(request, runtime);
}

model ListFavoriteReportsRequest {
  keyword?: string(name='Keyword'),
  pageSize?: int32(name='PageSize', example='10'),
  treeType?: string(name='TreeType', example='PAGE'),
  userId?: string(name='UserId', example='b5d8fd9348cc4327****afb604'),
}

model ListFavoriteReportsResponseBody = {
  requestId?: string(name='RequestId', example='D787E1A3-A93C-424A-B626-C2B05DF8D885'),
  result?: {
    data?: [ 
      {
        favorite?: boolean(name='Favorite', example='true'),
        gmtCreate?: string(name='GmtCreate', example='1640088615000'),
        gmtModified?: string(name='GmtModified', example='1640595729000'),
        hasEditAuth?: boolean(name='HasEditAuth', example='true'),
        hasViewAuth?: boolean(name='HasViewAuth', example='true'),
        name?: string(name='Name'),
        ownerName?: string(name='OwnerName'),
        ownerNum?: string(name='OwnerNum', example='1365*****238860'),
        publishStatus?: int32(name='PublishStatus', example='1'),
        treeId?: string(name='TreeId', example='977c7698-****-****-****-44b7304d20fc'),
        type?: string(name='Type', example='PAGE'),
        workspaceId?: string(name='WorkspaceId', example='523793cb-****-****-****-aa71c65ffa39'),
        workspaceName?: string(name='WorkspaceName'),
      }
    ](name='Data'),
    pageNum?: int32(name='PageNum', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
    totalNum?: int32(name='TotalNum', example='10'),
    totalPages?: int32(name='TotalPages', example='1'),
  }(name='Result'),
  success?: boolean(name='Success', example='true'),
}

model ListFavoriteReportsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListFavoriteReportsResponseBody(name='body'),
}

async function listFavoriteReportsWithOptions(request: ListFavoriteReportsRequest, runtime: Util.RuntimeOptions): ListFavoriteReportsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.keyword)) {
    query['Keyword'] = request.keyword;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.treeType)) {
    query['TreeType'] = request.treeType;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListFavoriteReports',
    version = '2020-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listFavoriteReports(request: ListFavoriteReportsRequest): ListFavoriteReportsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listFavoriteReportsWithOptions(request, runtime);
}

model ListRecentViewReportsRequest {
  keyword?: string(name='Keyword'),
  offsetDay?: int32(name='OffsetDay', example='10'),
  pageSize?: int32(name='PageSize', example='10'),
  queryMode?: string(name='QueryMode', example='1'),
  treeType?: string(name='TreeType', example='PAGE'),
  userId?: string(name='UserId', example='b5d8fd9348cc4327****afb604'),
}

model ListRecentViewReportsResponseBody = {
  requestId?: string(name='RequestId', example='D787E1A3-A93C-424A-B626-C2B05DF8D885'),
  result?: {
    data?: [ 
      {
        favorite?: boolean(name='Favorite', example='true'),
        gmtCreate?: string(name='GmtCreate', example='1640088615000'),
        gmtModified?: string(name='GmtModified', example='1640595729000'),
        hasEditAuth?: boolean(name='HasEditAuth', example='true'),
        hasViewAuth?: boolean(name='HasViewAuth', example='true'),
        latestViewTime?: string(name='LatestViewTime', example='1642067498000'),
        name?: string(name='Name'),
        ownerName?: string(name='OwnerName'),
        ownerNum?: string(name='OwnerNum', example='1365*****238860'),
        publishStatus?: int32(name='PublishStatus', example='1'),
        treeId?: string(name='TreeId', example='977c7698-****-****-****-44b7304d20fc'),
        type?: string(name='Type', example='PAGE'),
        viewCount?: long(name='ViewCount', example='7'),
        workspaceId?: string(name='WorkspaceId', example='523793cb-****-****-****-aa71c65ffa39'),
        workspaceName?: string(name='WorkspaceName'),
      }
    ](name='Data'),
    pageNum?: int32(name='PageNum', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
    totalNum?: int32(name='TotalNum', example='2'),
    totalPages?: int32(name='TotalPages', example='1'),
  }(name='Result'),
  success?: boolean(name='Success', example='true'),
}

model ListRecentViewReportsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListRecentViewReportsResponseBody(name='body'),
}

async function listRecentViewReportsWithOptions(request: ListRecentViewReportsRequest, runtime: Util.RuntimeOptions): ListRecentViewReportsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.keyword)) {
    query['Keyword'] = request.keyword;
  }
  if (!Util.isUnset(request.offsetDay)) {
    query['OffsetDay'] = request.offsetDay;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.queryMode)) {
    query['QueryMode'] = request.queryMode;
  }
  if (!Util.isUnset(request.treeType)) {
    query['TreeType'] = request.treeType;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListRecentViewReports',
    version = '2020-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listRecentViewReports(request: ListRecentViewReportsRequest): ListRecentViewReportsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listRecentViewReportsWithOptions(request, runtime);
}

model ListSharedReportsRequest {
  keyword?: string(name='Keyword'),
  pageSize?: int32(name='PageSize', example='10'),
  treeType?: string(name='TreeType', example='PAGE'),
  userId?: string(name='UserId', example='b5d8fd9348cc4327****afb604'),
}

model ListSharedReportsResponseBody = {
  requestId?: string(name='RequestId', example='D787E1A3-A93C-424A-B626-C2B05DF8D885'),
  result?: {
    data?: [ 
      {
        favorite?: boolean(name='Favorite', example='true'),
        gmtCreate?: string(name='GmtCreate', example='1640088615000'),
        gmtModified?: string(name='GmtModified', example='1640595729000'),
        hasEditAuth?: boolean(name='HasEditAuth', example='true'),
        hasViewAuth?: boolean(name='HasViewAuth', example='true'),
        name?: string(name='Name'),
        ownerName?: string(name='OwnerName'),
        ownerNum?: string(name='OwnerNum', example='1365*****238860'),
        publishStatus?: int32(name='PublishStatus', example='1'),
        treeId?: string(name='TreeId', example='977c7698-****-****-****-44b7304d20fc'),
        type?: string(name='Type', example='PAGE'),
        workspaceId?: string(name='WorkspaceId', example='523793cb-****-****-****-aa71c65ffa39'),
        workspaceName?: string(name='WorkspaceName'),
      }
    ](name='Data'),
    pageNum?: int32(name='PageNum', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
    totalNum?: int32(name='TotalNum', example='2'),
    totalPages?: int32(name='TotalPages', example='1'),
  }(name='Result'),
  success?: boolean(name='Success', example='true'),
}

model ListSharedReportsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListSharedReportsResponseBody(name='body'),
}

async function listSharedReportsWithOptions(request: ListSharedReportsRequest, runtime: Util.RuntimeOptions): ListSharedReportsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.keyword)) {
    query['Keyword'] = request.keyword;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.treeType)) {
    query['TreeType'] = request.treeType;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListSharedReports',
    version = '2020-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listSharedReports(request: ListSharedReportsRequest): ListSharedReportsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSharedReportsWithOptions(request, runtime);
}

model SaveFavoritesRequest {
  userId?: string(name='UserId', example='121344444790****'),
  worksId?: string(name='WorksId', example='d23e84a1-82a0-4292-bfdb-521306c3****'),
}

model SaveFavoritesResponseBody = {
  requestId?: string(name='RequestId', example='68383D95-D623-4059-AF1B-2310957FA332'),
  result?: boolean(name='Result', example='true'),
  success?: boolean(name='Success', example='true'),
}

model SaveFavoritesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SaveFavoritesResponseBody(name='body'),
}

async function saveFavoritesWithOptions(request: SaveFavoritesRequest, runtime: Util.RuntimeOptions): SaveFavoritesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  if (!Util.isUnset(request.worksId)) {
    query['WorksId'] = request.worksId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SaveFavorites',
    version = '2020-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function saveFavorites(request: SaveFavoritesRequest): SaveFavoritesResponse {
  var runtime = new Util.RuntimeOptions{};
  return saveFavoritesWithOptions(request, runtime);
}

